#include<iostream>
using namespace std;
int n,money[4],num[4];

int cal(int i){
	int tmp=0,an;
	if(n%num[i]!=0)tmp=(n/num[i])+1;
	else tmp=n/num[i];
	return an=money[i]*tmp;
}

int main(){
	cin>>n;
	for(int i=1;i<=3;i++){
		cin>>num[i]>>money[i];
	}
	
	int ans=0;
	ans=min(min(cal(1),cal(2)),cal(3));
	cout<<ans<<endl;
}